Skip to content

Latest commit

 

History

History
96 lines (74 loc) · 2.73 KB

send-message.md

File metadata and controls

96 lines (74 loc) · 2.73 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
    image 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. Also note that, session Id is the same as Room Id on Rocket.Chat. Click here to know more about Dialogflow sessions.

    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"
                      ]
                  }
              ]
          }
      }