Skip to content

Shape of webhook response such that the text message renders ... #96

@akanshaaa19

Description

@akanshaaa19

Summary

Problem Statement: The API response for a dynamic chapter list does not render items on separate lines as expected.

User Expectations: The user expected each chapter in the response to be rendered on a separate line when dynamically displayed in a message.

Actual Outcome: The response is returned as a \n separated string, but it does not format correctly, leading to a single line display rather than a list.

Error Messages: The bot responded with a timeout error due to the API issue.

Reproduction Steps:

  1. Call the webhook to retrieve the list of incomplete chapters.
  2. The API should return the chapter list in a single field as a text string with real line breaks.
  3. Use @results.chapter_list in the message box to replace it with the formatted list.
  4. Observe that the chapters are not displayed on separate lines.

Additional Context: The chapter list is dynamic, varies in length, and the user wants to avoid clutter. They find showing all chapters with completion status inelegant and cumbersome.

Source

Original message

Here's the list of incomplete/unmastered chapters:

1. Spectral Sequences and Derived Functors
2. Inter-universal Teichmüller Theory
3. Sheaves, Stacks, and Descent
5. Anabelian Geometry and Frobenioids
6. Motives and Periods
7. Noncommutative Geometry
8. Hodge Theaters and Their Mutations
10. Étale Cohomology and the Weil Conjectures
12. The Arithmetic Theta Function
13. Geometric Langlands Correspondence
14. p-adic Hodge Theory
15. Vertex Operator Algebras and Moonshine

Choose the chapter to practice next by entering its chapter number below.

I wonder what the response should look like. A \n separated string did not do the job, so I am left clueless. The number of items - more often than not - varies, per call.

What I want is each of the dynamic-list item on a separate line.

Full thread transcript

usurpesh: ```markdown
Here's the list of incomplete/unmastered chapters:

  1. Spectral Sequences and Derived Functors
  2. Inter-universal Teichmüller Theory
  3. Sheaves, Stacks, and Descent
  4. Anabelian Geometry and Frobenioids
  5. Motives and Periods
  6. Noncommutative Geometry
  7. Hodge Theaters and Their Mutations
  8. Étale Cohomology and the Weil Conjectures
  9. The Arithmetic Theta Function
  10. Geometric Langlands Correspondence
  11. p-adic Hodge Theory
  12. Vertex Operator Algebras and Moonshine

Choose the chapter to practice next by entering its chapter number below.


I wonder what the response should look like. A `\n` separated string did not do the job, so I am left clueless. The number of items - more often than not - varies, per call. 

What I want is each of the dynamic-list item on a separate line.

**Glific AI doc bot (bot):** Sorry, I am not able to answer this question due to timeout in API. Please try again later.

**Glific AI doc bot (bot):** Was this helpful in resolving your query? Or do you need further support?

**Glific AI doc bot (bot):** Thanks for letting us know! <@&983219484091383888> has been notified and will assist you shortly.

**usurpesh:** Deets:
1. The flow makes an API call that responds back with a list of incomplete chapters.
2. I want the user to choose one - by typing/entering the chapter number.
3. Now this list is dynamically created - its length varies, and its contents, well, are some subset of all the chapters.
4. A way out would be to simply print out all chapter names and suffix them with a incomplete/completed/mastered - but that's not only inelegant, but bothersome to the user, and also to design downstream to loop back into the same choice-set should the user mistakenly choose something already completed. (Why show when can't let choose?)

**priyanshusingh3026:** Flow Structure- Node 1 — Call Webhook
  Your API gets called. It returns the chapter list as a single text string (with real line breaks) stored in a field called input, plus a
  list of valid numbers like "1,2,3".

  Node 2 — Send Message
  Type @results.chapter_list in the message box. Glific auto-replaces this with the full formatted list text the webhook returned.

  Node 3 — Wait for Response
  Bot waits for the user to type a number. Save whatever they type as a result, e.g. user_pick.

  Node 4 — Call Webhook again
  Send the user's typed number and the valid choices to your API. API checks if the number is valid and returns success or failure.

  Node 5 — Split on webhook result
  If Success → move forward with the chosen chapter. If Failure → send "Invalid choice, try again" and loop back to Node 3.

</details>

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions