Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Convo.extractResponses method is not working #1562

Closed
kumarharsh opened this issue Jan 16, 2019 · 5 comments
Closed

Convo.extractResponses method is not working #1562

kumarharsh opened this issue Jan 16, 2019 · 5 comments

Comments

@kumarharsh
Copy link

Are you sure this is an issue with the Botkit core module?

Seems like it.

What are you trying to achieve or the steps to reproduce?

I created a brand new botkit instance by remixing a botkit-cms instance and a botkit-starter-slack instance to build a conversational slack bot. Then, I followed the instructions given in the slack bot setup checklist to configure the bot. I finally installed the app in my Slack team. I got the conversation working (using the default hello template provided in the botkit-cms). After that, I customized the conversation to accept user input as so:
image

Now, when I do the conversation, the bot does go through the full conversation, and it does have the user responses saved in the convo.transcript object. But when I try to extract the conversation values (as documented here: https://botkit.ai/docs/readme-studio.html#controllerstudioafter), the object comes up with no values:

  controller.studio.after('hello', function(convo, next) {
    console.log("TRANSCRIPT", convo.transcript);
    if (convo.status == 'completed') {
      var responses = convo.extractResponses();
      console.log("RESPONSES ARE", responses);
    }
    next();
  });

What was the result you received?

Output:

TRANSCRIPT [
  {
    "text": "G`day human!",
    "channel": "...",
    "capture_options": {
      "key": "temporary_value",
      "multiple": true
    },
    "handler": [
      [
        null
      ]
    ],
    "sent_timestamp": 1547641168153,
    "to": "...",
    "sent": true,
    "api_response": {
      "ok": true,
      "channel": "...",
      "ts": "1547641168.003200",
      "message": [
        null
      ]
    },
    "delivered": true
  },
  {
    "token": "...",
    "team_id": "...",
    "api_app_id": "...",
    "event": {
      "client_msg_id": "06aa5a48-b1bb-4a60-8295-f756b620a455",
      "type": "message",
      "text": "Hello bot, how are you? I wanted some help.",
      "user": "...",
      "ts": "1547641170.003400",
      "channel": "...",
      "event_ts": "1547641170.003400",
      "channel_type": "im"
    },
    "type": "direct_message",
    "event_id": "...",
    "event_time": 1547641170,
    "authed_users": [
      "..."
    ],
    "raw_message": {
      "token": "...",
      "team_id": "...",
      "api_app_id": "...",
      "event": [
        null
      ],
      "type": "event_callback",
      "event_id": "...",
      "event_time": 1547641170,
      "authed_users": [
        null
      ]
    },
    "_pipeline": {
      "stage": "receive"
    },
    "client_msg_id": "06aa5a48-b1bb-4a60-8295-f756b620a455",
    "text": "Hello bot, how are you? I wanted some help.",
    "user": "...",
    "ts": "1547641170.003400",
    "channel": "...",
    "event_ts": "1547641170.003400",
    "channel_type": "im",
    "team": "...",
    "events_api": true,
    "question": "G`day human!"
  },
  {
    "text": "why do you say that?",
    "channel": "...",
    "capture_options": {
      "key": "why_said",
      "multiple": true
    },
    "handler": [
      [
        null
      ]
    ],
    "sent_timestamp": 1547641172664,
    "to": "...",
    "sent": true,
    "api_response": {
      "ok": true,
      "channel": "...",
      "ts": "1547641172.003500",
      "message": [
        null
      ]
    },
    "delivered": true
  },
  {
    "token": "...",
    "team_id": "...",
    "api_app_id": "...",
    "event": {
      "client_msg_id": "...",
      "type": "message",
      "text": "Because I want to create you from nothing",
      "user": "...",
      "ts": "1547641174.003700",
      "channel": "...",
      "event_ts": "1547641174.003700",
      "channel_type": "im"
    },
    "type": "direct_message",
    "event_id": "...",
    "event_time": 1547640169,
    "authed_users": [
      "..."
    ],
    "raw_message": {
      "token": "...",
      "team_id": "...",
      "api_app_id": "...",
      "event": [
        null
      ],
      "type": "event_callback",
      "event_id": "...",
      "event_time": 1547641174,
      "authed_users": [
        null
      ]
    },
    "_pipeline": {
      "stage": "receive"
    },
    "client_msg_id": "...",
    "text": "My user input 2",
    "user": "...",
    "ts": "1547641174.003700",
    "channel": "...",
    "event_ts": "1547641174.003700",
    "channel_type": "im",
    "team": "T02LEFQ34",
    "events_api": true,
    "question": "why do you say that?"
  }
]
RESPONSES ARE { temporary_value: '', why_said: '' }

What did you expect?

The extractResponses() should have the user responses

Context:

  • Botkit version: 0.7.0
  • Messaging Platform: 0.0.2 (I've added the version of the botkit-starter-slack in package.json here)
  • Node version: 10.15.0 (from glitch console)
  • Os: Linux (glitch)
  • Any other relevant information:
@kumarharsh kumarharsh changed the title Convo.extractResponses method not working Convo.extractResponses method is not working Jan 16, 2019
@benbrown
Copy link
Contributor

That is unusual! Do you have the "collect multiple lines of input" option checked? This is likely the cause.

@kumarharsh
Copy link
Author

Yes, actually I do have that checked. I'll post a JSON of the CMS here soon.

@benbrown
Copy link
Contributor

When using that option, you have to take extra steps to configure the a condition that, when matched, continues with the dialog. See the screenshot below.

The default behavior of Botkit assumes the final line of input will match this "end" condition, so it discards it. If you have only one line, then the resulting value is empty.

screen shot 2019-01-16 at 11 11 15 am

screen shot 2019-01-16 at 11 11 33 am

@kumarharsh
Copy link
Author

@benbrown thanks! I couldn't have figured that one out on my own.

Is this the intended behaviour for the bot or a workaround? If yes, then should this be added to the docs (or maybe somewhere in the CMS UI near the checkbox for multi-line input?).

@benbrown
Copy link
Contributor

yes, this is the intended behavior. it should be enforced in the UI. thank you for your feedback.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants