Skip to main content
Skip table of contents

Getting data over HTTP

Sometimes you may want to use data from an external system within a script. This can be done by doing a HTTP request to the external system and extract data from the response.

YAML
config:
  conversationOwner: null
  conversationOwners:
    - identifier: conversationOwner
      channel: WhatsApp
  scriptLanguageVersion: 1
  scriptVersion: 1
  defaultDelay: 200
  lists:
    positive-answers:
      items:
        - Ja
    negative-answers:
      source: negative-answers.yml
flows:
  - id: main
    description: Entry flow for the bot
    steps:
      - !entry
        id: Entry-1
        actions: []
        clientActions: []
        matches:
          - opening
        allowRestart: true
        isCaseSensitive: true
        doCatchAll: true
      - !webrequest
        id: WebRequest-1
        actions: []
        clientActions: []
        retries: 0
        retryDelay: 0
        waitForResponse: true
        request:
          queryParameters: {}
          headers: {}
          url: https://webrequeststep.free.beeceptor.com/todos
          method: GET
          timeout: 60
          body: ''
        response:
          extracts:
            - var: firstTodoId
              source: '@body.json'
              selector: '[0].id'
            - var: firstTodoTitle
              source: '@body.json'
              selector: '[0].title'
      - !text
        id: Text-1
        actions: []
        clientActions: []
        message: >-
          The first todo in the response has id {firstTodoId} and its title is "{firstTodoTitle}".

The URL used here is generated by https://beeceptor.com/console/webrequeststep. Keep in mind this is a public URL viewable by everyone.


Previous: examples Intro

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.