Skip to content

Latest commit

 

History

History
95 lines (73 loc) · 2.44 KB

File metadata and controls

95 lines (73 loc) · 2.44 KB

Send Message

Action to send Message to Visitor. The sender for this message will be the Bot.

  • URL

    REST API URL can be found on Apps Page
    Sample Url for eg:
    http://localhost:3000/api/apps/public/783d8e4d-b06a-409a-aaf3-b37650dc0a26/incoming

  • Method:

    POST

  • Input Data Format

    JSON

  • Data Params

    Required:

    1. action = send-message

    2. sessionId=[string]

      Note. Session Id is the same session of Dialogflow

    3.   actionData: {
            `messages=[Array<string | QuickReplies>]`
        }

      Note: messages is an array of simple string messages and QuickReplies.

      Format for quick-replies is almost similar to this. Following is the format.

      {
          "text": string,
          "options": [
              string
          ]
      }
  • Success Response:

    • Code: 200
      Content: { result: "Your request was processed successfully" }
  • Error Response:

    • Code: 400 BAD REQUEST
      Content:
      { error: "Error: Session Id not present in request" }

    OR

    • Code: 500 Internal Server Error
      Content:
      { error : "Error occurred while processing perform-handover. Details:- [Error Details]" }
  • Sample Call:

    Curl

      curl "http://localhost:3000/api/apps/public/21b7d3ba-031b-41d9-8ff2-fbbfa081ae90/incoming" \
        -X POST \
        -d "{\n  \"action\": \"send-message\",\n  \"sessionId\": \"6uppPYfLa3rnDF6Fe\",\n  \"actionData\": {\n    \"messages\": [\n      \"hello\",\n      {\n        \"text\": \"Do you want to continue?\",\n        \"options\": [\n          \"YES\",\n          \"NO\"\n        ]\n      }\n    ]\n  }\n}" \
        -H "Content-Type: application/json" 

    HTTP

      POST /api/apps/public/21b7d3ba-031b-41d9-8ff2-fbbfa081ae90/incoming HTTP/1.1
      Host: localhost:3000
      Content-Type: application/json
    
      {
          "action": "send-message",
          "sessionId": "6uppPYfLa3rnDF6Fe",
          "actionData": {
              "messages": [
                  "hello",
                  {
                      "text": "Do you want to continue?",
                      "options": [
                          "YES",
                          "NO"
                      ]
                  }
              ]
          }
      }