Issue with knitr being stuck while integrating Azure chatbot responses in Rmd to PDF rendering

I'm using the R package elmer, specifically the chat_azure function, to connect to the
Azure chatbot. The connection and message exchange works perfectly in R. However, I'm
facing an issue when I try to integrate the chatbot responses into an R Markdown document
that I render to PDF.

Context

  • Tools: R, elmer package, knitr, R Markdown to PDF
  • Objective: Generate a PDF with chatbot-generated descriptions for plots and tables.

Issue

The Rmd rendering gets stuck at some chunks calling the chatbot. I suspect that this might
be due to the chatbot waiting for a user response or some backoff timeout mechanism.

What I've tried

  1. Running the chunks independently: Each chunk works fine when executed separately in an R session.
  2. Use the chat_async() function: I couldn't make it work.

Question

How can I ensure the knitr process does not get stuck while waiting for the Azure chatbot
response? Is there a way to handle or bypass the chatbot's waiting time during the
rendering process? The chatbot calls can be independent, they do not need to be within the same conversation with the chatbot.

Any suggestions or workarounds would be greatly appreciated. Thank you!